<template>
  <div class="dashboard-container">
    <div class="menu_wrap">
      <div class="menu_item" v-for="(item, index) in menus" :key="index" @click="menuClick(item)">
        <div class="icon"></div>
        <div>{{ item.title }}</div>
      </div>
    </div>
    
    <!-- 数据 -->
    <el-row :gutter="40" class="card-panel__col">
      <el-col :xs="24" :sm="12" :lg="6" class="card-panel__col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-user">
            <svg-icon icon-class="user" size="4em" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">访问数</div>
            <div class="card-panel-num">1000</div>
          </div>
        </div>
      </el-col>

      <el-col :xs="24" :sm="12" :lg="6" class="card-panel__col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-message">
            <svg-icon icon-class="message" size="4em" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">消息数</div>
            <div class="card-panel-num">1000</div>
          </div>
        </div>
      </el-col>

      <el-col :xs="24" :sm="12" :lg="6" class="card-panel__col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-money">
            <svg-icon icon-class="money" size="4em" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">收入金额</div>
            <div class="card-panel-num">1000</div>
          </div>
        </div>
      </el-col>
      <el-col :xs="24" :sm="12" :lg="6" class="card-panel__col">
        <div class="card-panel">
          <div class="card-panel-icon-wrapper icon-shopping">
            <svg-icon icon-class="shopping" size="4em" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">订单数</div>
            <div class="card-panel-num">1000</div>
          </div>
        </div>
      </el-col>
    </el-row>

    <div class="card_chart">
      
    </div>

    <!-- <component :is="currentRole" /> -->
  </div>
</template>

<script>
import SvgIcon from '@/components/SvgIcon/index.vue';

import { mapGetters } from 'vuex'
import adminDashboard from './admin'
import editorDashboard from './editor'

export default {
  name: 'Dashboard',
  components: { adminDashboard, editorDashboard },
  data() {
    return {
      currentRole: 'adminDashboard',
      // 类型：1: 采购入库，2: 销售出库，3: 同价调拨， 4: 其他入库，5: 采购退货，6: 报溢单，7: 报损单，8: 其他出库
      menus: [
        { title: '采购入库', path: '/order/add/0', type: 'addOrder1', params: { oType: '1' } },
        { title: '销售出库', path: '/order/add/0', type: 'addOrder2', params: { oType: '2' } }
      ]
    }
  },
  computed: {
    ...mapGetters([
      'roles'
    ])
  },
  created() {
    console.log('process.env.NODE_ENV==', process.env.NODE_ENV)
    if (!this.roles.includes('admin')) {
      this.currentRole = 'editorDashboard'
    }
  },
  methods: {
    menuClick({ path, type, params = {} }) {
      if (['addOrder1', 'addOrder2'].includes(type)) {
        this.$router.push({ path: `${path}/${new Date().getTime()}`, query: params });
      }
    }
  }
}
</script>

<style lang="scss">
.menu_wrap {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  .menu_item {
    padding: 20px;
    margin: 10px;
    box-shadow: 5px 5px 5px #ccc;
    cursor: pointer;
    &:active, &:focus {
      // background: #ccc;
      opacity: 0.8;
    }
  }
}
// #region

.card-panel__col {
    margin-bottom: 12px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
    .svg-icon {
      width: 4em;
      height: 4em;
    }
    .icon-message {
      color: #36a3f7;
    }

    .icon-user {
      color: #40c9c6;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3;
    }

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-user {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3;
      }
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px 20px 0;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
        text-align: right;
      }
    }
  }


// #endregion

</style>
